(function (): void {
    const docWidth = 1920;
    const doc: Document = window.document,
        docEl: HTMLElement = doc.documentElement,
        resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize';
    const recalc = (function refreshRem() {
        const clientWidth = docEl.getBoundingClientRect().width;
        docEl.style.fontSize = Math.max(Math.min(20 * (clientWidth / docWidth), 44.2), 8.55) * 5 + 'px';
        return refreshRem;
    })();

    if (!doc.addEventListener) {
        return;
    }

    window.addEventListener(resizeEvt, recalc, false);
    doc.addEventListener('DOMContentLoaded', recalc, false)
}

)()